<template>
	<view class="community">
		<view class="head_bg" style="position: relative;"></view>
		<view class="big_box" style="top: -190rpx;padding-top: 20rpx;">
			<view class="equ_list" v-for="(info,index) in list" :key="index">
				<view class="ele_title" style="padding-top: 20rpx;">
					<view class="ele_title_left">
						<view class="ele_title_inner">{{info.residential_quarters_name}}(网关编号)</view>
						<view class="ele_address">
							<text>{{info.residential_quarters_address}}</text>
						</view>
					</view>
					<view class="falt_status red_color" v-if="info.notification_type==0" >网关离线</view>
					<view class="falt_status red_color" v-if="info.notification_type==1" >插座离线</view>
				</view>
				<view class="equ_list_inner">					
					<view class="equ_list_inner_text">通知内容:<text style="color: #EC692F;">{{info.notification_information}}</text></view>
					<view class="equ_list_inner_text">上报时间:{{info.notification_time}}</view>
				</view>
			</view>
			<view v-if="list.length==0" class="text-gray text-df text-center bg-white padding-lg padding-left-lg be-gray">
				<image src='../../../common/img/no_data.png' style="width:275rpx;height:312rpx;"></image>
			</view>
		</view>
		<!-- <view style="height:150rpx;"></view> -->
		
		<view v-if="list.length>0" class="text-black text-df text-center bg-white padding-sm padding-left-lg be-gray">
			{{loadingTxt}} 共({{list.length}}条记录)
		</view>
	</view>
</template>

<script>
	let page=1,timer=null
	export default {
		data() {
			return {
				list:[],
				total:0,
				loadingTxt:'加载更多',
				info:{
				  notification_type:0,//	整型	通知类型 0 网关离线 1 插座离线
				  notification_information:'',//	字符串	通知内容
				  residential_quarters_name:'',//		字符串	小区名称
				  residential_quarters_address:'',//		字符串	小区地址
				  notification_time:'',//		时间	通知时间

				}
			}
		},
		onShow() {
			page=1;
			this.getInfo();
		},
		methods: {
			expressTemplateChange(e){
				console.log(e)
				this.index = e.detail.value
			},
			toFaltDetail(){
				uni.navigateTo({
					url: '/pages/breakdown/falt_detail/falt_detail'
				})
			},
			getInfo(){
				let that=this;
				let pan = that.pageindex;
				that.http.tokenreq({
					url: 'info/v1/offlinelist',
					data: {
				    "pageindex":this.page
					}
				}).then((res) => {
					let e=res.data;
					if(e.code==0 && e.success){
						this.list = e.rows;
						this.totle= e.total;
						page++
					}
				})
			},
			getmorelist(){
				this.loadingTxt='加载中'
				let that=this;
				that.http.tokenreq({
					url: 'info/v1/offlinelist',
					data: {
				    "pageindex":this.page
					}
				}).then((res) => {
					console.log("res="+JSON.stringify(res));
					let e=res.data;
					if(e.code==0 && e.success){
						if(e.rows.length==0){
							that.loadingTxt="已经加载全部";
							return;
						}
						that.list=that.list.concat(e.rows);
						page++;
					}else{
						uni.showModal({
							content:e.message,
							showCancel:false,
						})
					}
				})
			},
			onReachBottom() {
				//阻止重复加载
				if(timer !== null){
					clearTimeout(timer)
				}
				timer=setTimeout(()=>this.getmorelist(),500)
				// this.getMoreNews()
			},
		}
	}
</script>
